<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="./layuimini-v2/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="./layuimini-v2/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label required">商品ID</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="text" name="name" lay-verify="required" lay-reqtext="商品不能为空" placeholder="请输入商品ID" value="" class="layui-input">-->
<!--            <tip>填写商品ID</tip>-->
<!--        </div>-->
<!--    </div>-->

    <div class="layui-form-item">
        <label class="layui-form-label required">商品名</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" lay-reqtext="商品不能为空" placeholder="请输入商品名" value="" class="layui-input">
            <tip>填写商品名</tip>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">商品类别ID</label>
        <div class="layui-input-block">
            <input type="text" name="tgoodsCategoryId" lay-verify="required" lay-reqtext="商品不能为空" placeholder="请输入商品类别ID" value="" class="layui-input">
            <tip>填写商品类别ID</tip>
        </div>
    </div>
    <!-- <div class="layui-form-item">
        <label class="layui-form-label required">商品种类</label>
        <div class="layui-input-block">
            <input type="radio" name="gender" value="1" title="是" checked="">
            <input type="radio" name="gender" value="2" title="否">
        </div>
    </div> -->
<!--    <div class="layui-form-item" >-->
<!--        <label class="layui-form-label required">商品种类</label>-->
<!--        <div class="layui-input-block">-->
<!--        <select >-->
<!--            <option name="gender" value="1" >shi</option>-->
<!--            <option name="gender" value="2">fou</option>-->
<!--        </select>-->
<!--        </div>-->
<!--    </div>-->

    <div class="layui-form-item">
        <label class="layui-form-label required">售价</label>
        <div class="layui-input-block">
            <input type="number" name="cashPrice" lay-verify="required" lay-reqtext="售价不能为空" placeholder="请输入售价" value="" class="layui-input">
            <tip>填写数字格式</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">会员积分价</label>
        <div class="layui-input-block">
            <input type="text" name="pointsPrice" lay-verify="required" lay-reqtext="会员积分价不能为空" placeholder="请输入会员积分价" value="" class="layui-input">
            <tip>填写数字格式</tip>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">商品详情</label>
        <div class="layui-input-block">
            <input type="text" name="describe" lay-verify="required" lay-reqtext="商品详情不能为空" placeholder="请输入商品详情" value="" class="layui-input">
            <tip>填写文本格式</tip>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">是否上架</label>
        <div class="layui-input-block">
            <input type="radio" name="isDelete" value="1" title="是" checked="">
            <input type="radio" name="isDelete" value="2" title="否">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">库存</label>
        <div class="layui-input-block">
            <input type="number" name="stock" lay-verify="required" lay-reqtext="商品库存不能为空" placeholder="请输入商品库存" value="" class="layui-input">
            <tip>填写数字格式</tip>
        </div>
    </div>
    <!-- <div class="layui-form-item">
        <label class="layui-form-label required">手机</label>
        <div class="layui-input-block">
            <input type="number" name="phone" lay-verify="required" lay-reqtext="手机不能为空" placeholder="请输入手机" value="" class="layui-input">
        </div>
    </div> -->

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script src="./layuimini-v2/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            console.log(data.field);
            $.ajax({
                type: "POST",
                url: "https://douzi.wiki:7000/GROW/api/goods/page",
                contentType: "application/json",
                dataType: "json",
                data: JSON.stringify(data.field),
                success: function (res) {
                    window.location.href = "HotelUser-hotel.html";
                },
                error: function (res) {},
            });



            var index = layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            }, function () {

                // 关闭弹出层
                layer.close(index);

                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.layer.close(iframeIndex);

            });

            return false;
        });

    });
</script>
</body>
</html>